Gemini Proxy
Font Manager Redux
* Author: Andy Hertzfeld
* Story Date: March 1985
* Topics: Software Design, Technical, Personality, Allnighters, QuickDraw
* Characters: Bud Tribble, Steve Jobs, Jerome Coonen, Bill Atkinson, Bruce Horn, Larry Kenyon, Burrell Smith, Steve Capps
* Summary: I continued to work on the Font Manager even after I left Apple
Innovation often requires discarding finished work when a better solution comes along. Each new improvement may impact prior work, so you have to be willing to retool the older parts of a design to better integrate the newer parts as they emerge. One example of this for the Macintosh was the development of font manager, which had to be rewritten a few different times as the system evolved.
Bill Atkinson's QuickDraw graphics package did all the work of measuring and drawing text, but it didn't want to deal with system-dependent details like reading from the file system. The font manager's main job was to load fonts for QuickDraw, given a font family, a size and a style, so QuickDraw could just blast out characters without having to worry about how fonts are stored and loaded.
The initial implementation of the font manager simply included a few built-in fonts that were linked with the system, and it returned the system font if you requested one that wasn't built-in. The initial system font that we used through most of 1981 was one that we borrowed from Smalltalk called "Cream".
In the spring of 1982, the first implementation of our user interface software was beginning to come together. We wanted to allow application writers to use a variety of fonts, so we had to provide a way to load fonts from disk and cache them in memory. We also had to load hunks of code called "drivers" in a similar fashion, so Larry Kenyon and I collaborated on some code to load and cache objects from disk that we called the "object manager" that was used by the font manager.
Bill Atkinson had recently given QuickDraw the ability to scale bitmaps, including text, so we added support in the font manager for scaled fonts, which included heuristics to find the font that best satisfied a given request, if none were perfect. If we didn't have a font at the requested size, we could make one by scaling. But scaled text looked kind of lumpy, so we added a way for an application to choose if it wanted it or not.
Meanwhile, Bruce Horn was busy
implementing the resource manager.
We added a number of refinements to
the font manager in 1983, like a
In early 1985, Jerome Coonen was getting the software team revved up to do a 128K version of the ROM, that would eventually ship with the Mac Plus in January 1986. It incorporated lots of bug fixes, and some newer subsystems like AppleTalk and a better, hierarchical file system. There was so much extra space available that it even incorporated a ROM-based resource file for system resources, to speed up booting and save memory. Jerome solicited my suggestions for improvements, and I responded with a pretty long list.
Among other things, I suggested a
major overhaul of the font manager.
Even though I was no longer an
Apple employee (see Things Are
On one such visit, in late February 1985, Steve asked me what I thought of the 128K ROM effort. I complained that it wasn't ambitious enough, and mentioned the font manager changes when Steve asked for an example. But I didn't expect his response.
"If you think that's so important, why don't you go ahead and do it yourself", Steve told me. "There would be time to get it done if you pitched in. Maybe we could give you a few Macs in exchange for doing it."
I told him I'd think about. Bud Tribble came by the next day to discuss it with me, and I agreed to develop a new font manager for the 128K ROM in exchange for three 512K Macintoshes, which I had Apple ship directly to my brothers and sister as gifts. All the code for the new ROM was supposed to be completed within a month, so I'd have to drop what I was doing to get the font manager done in time.
Pretty soon, I had the new font manager going, which used a new resource type called "FOND" to describe all of the properties of a font family, including the resource IDs of the font bitmaps. This allowed us to support tens of thousands of font families instead of a mere 128 like the old design. I also got the fractional width support going, but I needed some changes in QuickDraw to make it so applications could actually use it.
I talked with Bill about
implementing the required changes
We were all surprised when Bill showed up at Apple the next day, excited to give us a demo of ovals drawing almost twice as fast as they used to. Apparently, when he started looking at the code yesterday evening he got excited about working on QuickDraw again. He started to fix the bugs we identified, and one thing led to another, and he soon he saw a half dozen ways to improve things. I was happy that Bill was excited about QuickDraw again, but a little bit afraid that he had swung too far in the opposite direction.
At this point, there was only around a week left before code freeze, but it seemed like the font manager was just about finished. Bill implemented measuring with the fractional widths, and it seemed to work great. But then, the evening before we were going to freeze the code, I got a call from Bill at around 8pm.
"Hey, Andy, I've got some great news. I can speed up text drawing by more than 40%! But I need a little help from the font manager."
It turns out that Bill had realized that, on the average, since most text was lower case, characters only used around half of the total height of the strike bitmap - only a few characters had descenders, and most didn't go all the way to the top, either. QuickDraw usually could just skip the blank parts in the characters, saving lots of time.
QuickDraw didn't have time to measure the tops and bottoms of the characters on the fly, but it was a perfect job for the font manager, which could do it once, right after it loaded a new font into memory. For each character, it calculated an offset and a length, telling Bill where to start and stop the drawing. Bill told me the format of the table that he'd like the font manager to supply, and asked me if I thought I could do it.
I thought that it was crazy to
attempt something like this with
We crossed our fingers when we tried it out, but luckily both of our parts worked the first time, with Bill's tests showing that we achieved the projected 40% speed-up. Of course, the code freeze ended up slipping for other reasons, so we didn't really have to rush like we did, but the urgency made it a little bit more fun, I guess.
---
you're on gemi.dev/apple-folklore/105.gmi